<?php

namespace App\Admin\Actions;

use Encore\Admin\Actions\BatchAction;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;

class SeaAction extends BatchAction
{
    public $name = '延长公海到期时间';

    public function handle(Collection $collection,Request  $request)
    {
        $day=$request->get('day');
        foreach ($collection as $model) {
            $model->deal_time=Carbon::parse($model->deal_time)->addDays($day)->timestamp;
            $model->save();
        }

        return $this->response()->success('提交成功...')->refresh();
    }
    public function form()
    {

        $this->integer('day', '延长天数')->rules('required');
    }
}
